#ifndef _READYQUEUEH_
#define _READYQUEUEH_

#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))

// #define foreach(item, array) \
//     for(int keep=1, \
//             count=0,\
//             size=sizeof (array)/sizeof *(array); \
//         count != size; \
//         keep=1, count++) \
//       for(item = (array)+count; keep; keep = !keep)


typedef struct list_head {
	struct list_head *prev;
	struct list_head *next;
} node;

typedef struct st_pcb {
	node list;
	pid_t pid;
    int priority;
    int tsc;
    long state;
	unsigned int time_slice;
	struct st_pcb *parent;
	struct list_head children;
	struct files_struct *files;
	struct mm_struct *mm;
	unsigned int flags;
	int registers[32];
} pcb;

typedef struct st_ready_queue {
	pcb *front, *rear, *current;
    int size;
    const char *sched_mode;

//    void (*cmd_mode) ( const void *cmd_param )
        /*{
            int run_mode = atoi( (char *)cmd_param );
            
            switch(run_mode) {
                case FCFS : break;
		        case SJF : break;
        		case RR : break;
            }
        }*/

} task_rq;

void enqueue_task(task_rq *, pcb *);
//pcb *dequeue_task(task_rq *);
void dequeue_task(task_rq *);
int is_empty(task_rq *);
int get_queue_size(task_rq *);
pcb *get_first_task(task_rq *);
pcb *get_last_task(task_rq *);
task_rq *init_task_queue();
void clear_queue(task_rq *);
void update_task(pid_t, pcb);
//void clear_pcb();
//void get_mode ( const void *cmd_pararm )

#endif
